


import 'package:bt_tool/basic/bt_color_tool.dart';
import 'package:bt_tool/basic/bt_common_define.dart';
import 'package:bt_tool/basic/bt_controller.dart';
import 'package:bt_tool/basic/bt_nav_tool.dart';
import 'package:bt_tool/basic/bt_theme.dart';
import 'package:bt_tool/basic/bt_theme_color.dart';
import 'package:bt_tool/widget/bt_base_btn_widget.dart';
import 'package:bt_tool/widget/bt_check_box.dart';
import 'package:bt_tool/widget/bt_form_select_widget.dart';
import 'package:bt_tool/widget/bt_text_field.dart';
import 'package:bt_tool/widget/bt_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_demo/common/config/app_config.dart';
import 'package:flutter_demo/common/config/app_theme_color_config.dart';
import 'package:flutter_demo/tools/donext/controller/do_next_create_controller.dart';
import 'package:get/get.dart';


class DoNextCreatePage extends BTStatefulWidget{

  const DoNextCreatePage({super.key,super.routerConfig});

  @override
  State<StatefulWidget> createState() {
    return DoNextCreateState();
  }

}

class DoNextCreateState extends BTState<DoNextCreatePage>{

  final DoNextCreateController ctl = DoNextCreateController();

  @override
  BTController btCtrl() {
    return ctl;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: BTNavTool.createAppBar(title: "创建",context: context),
      body: Container(
        constraints: const BoxConstraints.expand(),
        color: AppThemeColor.contentBgColor,
        padding: const EdgeInsets.all(10),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            SizedBox(
              width: 200,
              height: 30,
              child: Obx(()=>BTFormSelectWidget(
                titleStr: "所属项目：",
                dataList: ctl.projectSelectModelList.value,
                callback: (model){
                  ctl.selectProjectId = model.id;
                  ctl.getData();
                },
              )),
            ),
            const SizedBox(height: 10,),
            const Text("内容"),
            const SizedBox(height: 10,),
            Expanded(child: Container(
              constraints: const BoxConstraints.expand(),
              child: BTTextFieldWidget(
                btTextFieldController: ctl.inputCtl,
                maxLine: BTTextFieldWidget.maxLineDefine,
                isIgnoreClearBtn: true,
              ),
            )),
            const SizedBox(height: 10,),
            const Text("结束时间"),
            const SizedBox(height: 10,),
            timeWidget(),
            const SizedBox(height: 10,),
            bottomActionWidget(),
            const SizedBox(height: 10,),
          ],
        ),
      ),
    );
  }

  Widget bottomActionWidget(){
    return Row(
      children: [
        BTBtnTextWidget(
          bgColor: AppThemeColor.mainColor,
          constraints: const BoxConstraints.expand(width: 100,height: 40),
          text: "保存",
          textColor: Colors.white,
          onTap: () => ctl.create(context),
          alignment: Alignment.center,
        ),

      ],
    );
  }


  Widget timeWidget(){
    return Obx(()=> BTCheckBoxGroup(
      titleArray: const ["今天完成","1天后","2天后","3天后","4天后","5天后","6天后"],
      clickCallback: (i){
        ctl.endTimeType.value = i;
      },
      selectIndex: ctl.endTimeType.value,
      selectImg: Image.asset(btPngPath("bt/bt_check_box_sel")),
      normalImg: Image.asset(btPngPath("bt/bt_check_box_nor")),
    ));
  }

}
